#include <my_header.h>

/* Usage:  */
int main(int argc, char *argv[]){                                  
    int pipefd[2];
    pipe(pipefd);

    int son_fd = fork();
    ERROR_CHECK(son_fd, -1, "fork");

    if(son_fd == 0)
    {
        // 子进程读
        close(pipefd[1]);   // 关闭写
        char buf[6];
        read(pipefd[0], buf, 6);
        while(1);
        printf("child get message:%s\n", buf);
    }else{
        // 父进程写
        close(pipefd[0]);   //关闭读
        write(pipefd[1], "hello", 5);
        
        // wait(NULL);
    }
    return 0;
}


